草庐IT

php - 单例继承

全部标签

c# - 从抽象类引用继承的 EntitySet 的 dapper PropInfo Setter 为 null

我正在尝试用一些简洁的查询替换令人讨厌的LINQ2SQL命中以提高性能。这样做时,我必须将一堆不同的对象编织在一起,以创建保存ASN信息所需的所有信息所需的大对象。我目前遇到的问题是抽象类Orders,该类由两个单独的类AutionOrder和MerchantOrder使用鉴别器属性实现。由于我无法使用dapper创建抽象类对象,因此我改用其中一个公共(public)类。但是,当它构建对象时,它在GetSettableProps内部失败,它找到了正确的DeclaringType但是GetProperty方法在它返回null时正在寻找internal或EntitySet的属性。我尝试使用

c# - 接口(interface)继承多个接口(interface) : how is this handled by a C# compiler?

最近我发现C#允许Aninterfacecaninheritfromoneormorebaseinterfaces.例如,Caliburn.Micro中的IScreen在http://caliburnmicro.codeplex.com/SourceControl/latest#src/Caliburn.Micro/IScreen.cs中执行此操作namespaceCaliburn.Micro{publicinterfaceIScreen:IHaveDisplayName,IActivate,IDeactivate,IGuardClose,INotifyPropertyChangedE

c# - 将接口(interface)转换为它不继承的另一个接口(interface)

我希望这里有人可以解释我所做的错误假设。在C#4.0中,我有2个接口(interface)和一个实现它们的类。在一个方法中,我声明了一个具有第一个接口(interface)类型的变量,使用实现这两个接口(interface)的类实例化它,并且可以以某种方式成功地将它转换为第二个接口(interface),如以下代码所示:publicinterfaceIFirstInterface{voidMethod1();}publicinterfaceISecondInterface{voidMethod2();}publicclassInterfaceImplementation:IFirstI

c# - DLL 中的单例类可以跨进程共享吗?

我正在创建一个自定义的.net硬件框架,其他程序员将使用它来控制某些硬件。他们将添加对我们的DLL的引用以访问我们的硬件框架。我需要一个可以从多个应用程序(进程)访问的共享类。单例模式似乎是我所需要的,但它只适用于进程内的多个线程。我可能完全错了,但这是我目前拥有的C#代码的示例。我不禁觉得设计不正确。我希望我可以分享更具体的信息,但我不能。我必须强调,我无法控制客户的申请。解决方案必须包含在框架(DLL)本身中。框架:(共享DLL)publicclassResources{staticreadonlyResourcesm_instance=newResources();publics

c# - 泛型与继承(当不涉及集合类时)

这是thisquestion的扩展甚至可能是其他一些问题的重复(如果是这样,请原谅我)。我seefromMSDN泛型通常与集合一起使用Themostcommonuseforgenericclassesiswithcollectionslikelinkedlists,hashtables,stacks,queues,treesandsoonwhereoperationssuchasaddingandremovingitemsfromthecollectionareperformedinmuchthesamewayregardlessofthetypeofdatabeingstored.我

c# - 我可以用这种方式为所有派生的单例定义一个抽象类吗?

这是我的抽象类,每次我想制作一个Singleton时都必须派生它:publicabstractclassSingletonwhereT:Singleton{privatestaticreadonlyLazy_instance=newLazy(()=>{varconstructor=typeof(T).GetConstructor(BindingFlags.NonPublic|BindingFlags.Instance,null,newType[0],null);return(T)constructor.Invoke(null);});publicstaticTInstance{get{

c# - AutoMapper——继承映射不​​工作,相同的源,多个目的地

我可以在AutoMapper(v2.2)中对源类型相同但目标类型不同的映射使用继承映射吗?我有这样的基本情况(真正的类有更多的属性):publicabstractclassBaseViewModel{publicintCommonProperty{get;set;}}publicclassViewModelA:BaseViewModel{publicintPropertyA{get;set;}}publicclassViewModelB:BaseViewModel{publicintPropertyB{get;set;}}ViewModelA和ViewModelB是同一实体类的不同表示

C# 向 COM 公开 - 接口(interface)继承

假设我有一个实现IBaseClass的类BaseClass然后我有一个继承IBaseClass的接口(interface)IClass。然后我有一个名为class的类,它实现了IClass。例如:[ComVisible(true),InterfaceType(ComInterfaceType.IsDual),Guid("XXXXXXX")]publicinterfaceIBaseClass{[PreserveSig]stringGetA()}[ComVisible(true),InterfaceType(ComInterfaceType.IsDual),Guid("XXXXXXX")]

c# - 条件运算符不适用于继承相同基类型的两种类型

为什么条件运算符(?:)在与从单个基类型继承的两个类型一起使用时不起作用?我的例子是:ActionResultfoo=(someCondition)?RedirectToAction("Foo","Bar"):Redirect(someUrl);长格式工作正常的地方:ActionResultfoo;if(someCondition){foo=RedirectToAction("Foo","Bar");}else{foo=Redirect(someUrl);}RedirectToRouteResult和RedirectResult这两个返回类型都继承自ActionResult。

c# - 多线程 C# 应用程序中的惰性单例

我正在开发一个使用WCFWeb服务的多线程C#应用程序。与web服务的连接将有一个特定的超时时间,我们可以定义该超时时间,超时后它将关闭。我希望使用单例类来存储与Web服务的连接。我正在尝试按如下方式获取实例:CLazySingletonins=CLazySingleton.Instance;stringconnection=CLazySingleton.abc;下面是单例类的代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceLazySingleton{pu